<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>08_扩展运算符 spread operator intro</title>
	</head>
	<body>
		<!--  
		  rest剩余参数：将多个参数整合为一个数组
		  扩展运算符：  将可遍历对象的元素扩展为一个新的参数序列 
	   -->
	   <script type="text/javascript">
	   	// 数组合并
	   	// es5
	   	var fruit=["apply", "bananas", "pear"]
	   	var newFruit=["orange", "mongo"]
		// 新添加的元素会成为二维数组
	   	// fruit.push(newFruit);
	   	// console.log(fruit);// ["apply", "bananas", "pear", Array(2)]
	   	
	   	// 需要使用apply解决
	   	// fruit.push.apply(fruit,newFruit);
	   	// console.log(fruit);// ["apply", "bananas", "pear", "orange", "mongo"]
	   	
	   	// es6
	   	// 使用rest剩余参数解决
	   	fruit.push(...newFruit);
	   	console.log(fruit);//["apply", "bananas", "pear", "orange", "mongo"]
		
		// 数组复制(深拷贝)
		// es5
		const currentMembers5=[].concat(fruit)
		// es6
		const currentMembers6=[...fruit]
	   </script>
	</body>
</html>
